<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var fun1 = function () {
            console.log(this)
        }
        function fun2() {
            console.log(this)
        }
        window.fun1()
        window.fun2()

        console.log(window)
        var fun3 = () => {
            console.log(this)
        }
        fun3()

        console.log(this)


        var obj222 = {
            name: "lucy",
            print: () => {
                console.log(this)
            }
        }
        obj222.print()


        var obj333 = {
            name: "eric",
            print1() {
                var print2 = () => {
                    console.log(this)
                }
                print2()
            }
        }
        obj333.print1()

        var obj1 = {
            print: function () {
                console.log(this)
            }
        }
        obj1.print()

        var foo = 123;
        function print() {
            this.foo = 234;
            console.log(this);
            console.log(foo);
        }
        print();


        //var a = 1;
        //function foo() {
        //    console.log(this.a);
        //}
        //var obj = {
        //    a: 10, 
        //  bar() {
        //    foo();
        //}
        //}



        //obj.bar();
        //var obj = {
        //    name: 'edward',
        //    func: function () {
        //        var that = this;
        //        console.log(this.name);
        //        console.log(that.name);
        //        (function () {
        //            console.log(this)
        //            console.log(this.iiii)
        //            console.log(that.name)
        //        })()
        //    }
        //}
        // obj.func()
        var name = 'Javascript';
        function demo() {
            var name = 'CSS';
            var other = {
                name: 'HTML',
                fn: () => {
                    var name = 'Vue';
                    console.log(this.name)
                }
            }
            return other
        }
        demo().fn()

    </script>
</body>

</html>